import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

// 展示部分
import Exhibition from './views/Exhibition/Exhibition.vue'
import ExIndex from './views/Exhibition/Index.vue'
import ExIchTips from './views/Exhibition/IchTips.vue'
import ExProvince from './views/Exhibition/Province.vue';

// 活动部分
import Activity from './views/Activity/Activity.vue'
import AcIndex from './views/Activity/Index.vue'

Vue.use(Router)

const router = new Router({
	mode: 'history',
	routes: [{
			path: '/',
			redirect: '/home'
		},
		{
			// 系统首页
			path: '/home',
			name: 'home',
			component: Home,
		},
		{
			// 第一部分
			path: '/exhibition',
			component: Exhibition,
			// 第一部分子页面
			children: [{
					path: "",
					redirect: 'index',
				},
				{
					path: 'index',
					name: 'exIndex',
					component: ExIndex
				},
				{
					path: 'tips',
					name: 'exTips',
					component: ExIchTips
				},
				{
					path: 'province/:provinceId',
					name: 'province',
					component: ExProvince,
				}
			]
		},
		{
			// 第二部分
			path: '/activity',
			component: Activity,
			// 第二部分子页面
			children: [{
					path: '',
					redirect: 'index'
				},
				{
					path: 'index',
					name: 'acIndex',
					component: AcIndex
				}
			]
		}
	]
})
/**
 *  路由守卫，登录拦截
 */
router.beforeEach((to, from, next) => {
	// to将要访问的路径
	// from 代表从那个路径跳转而来
	// next 一个函数表示放行
	// next("/login") 强制跳转

	// if (to.path == "/login") return next();
	// const token = window.sessionStorage.getItem("access_token");
	// if (!token) return next("/login"); //如果是未登录装套转到登录页面
	next();
})
export default router;
